package manager;

import java.sql.SQLException;
import java.util.ArrayList;
import data.dao.*;
import data.dto.*;
import data.searchdto.*;
import data.dao.daoFactory.*;
import data.dao.daoImplementation.NotFoundException;

public class LeaveTypeManager {
	private LeaveTypeDAO leaveTypeDAO;
	private CompensationConsumedDAO compensationConsumedDAO;

	private ArrayList<LeaveTypeDTO> leaveTypelist;
	private ArrayList<CompensationLeaveUserDetails> CompensationLeaveUserDetailslist;

	public LeaveTypeManager() {
		this.leaveTypeDAO = LeaveFactory.loadInstance().getLeaveTypeDAO();
		this.compensationConsumedDAO = LeaveFactory.loadInstance()
				.getCompensationConsumedDAO();
	}

	public ArrayList<LeaveTypeDTO> findAllLeaveType() throws LeaveDAOException, SQLException, data.dao.daoImplementation.SQLException {
		leaveTypelist = new ArrayList<LeaveTypeDTO>();
		try {
			leaveTypelist = leaveTypeDAO.findAllLeaveType();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return leaveTypelist;
	}

	public void insertLeaveDetailType(LeaveTypeDTO LeaveDetail)
			throws LeaveDAOException, SQLException, data.dao.daoImplementation.SQLException {
		try {
			leaveTypeDAO.insertLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void updateLeaveDetailType(LeaveTypeDTO LeaveDetail)
			throws LeaveDAOException, SQLException, NotFoundException, data.dao.daoImplementation.SQLException {
		try {
			leaveTypeDAO.updateLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteLeaveDetailType(LeaveTypeDTO LeaveDetail)
			throws LeaveDAOException, SQLException, NotFoundException, data.dao.daoImplementation.SQLException {
		try {
			leaveTypeDAO.deleteLeaveDetailType(LeaveDetail);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public ArrayList<CompensationLeaveUserDetails> findCompensationLeave(
			CompensationConsumedSearchDTO compensationconsumedSearchDTO)
			throws LeaveDAOException, NotFoundException {
		CompensationLeaveUserDetailslist = new ArrayList<CompensationLeaveUserDetails>();
		try {
			compensationConsumedDAO
					.findCompensationLeave(compensationconsumedSearchDTO);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return CompensationLeaveUserDetailslist;
	}

	public ArrayList<CompensationLeaveUserDetails> findAllCompensationLeave()
			throws LeaveDAOException {
		CompensationLeaveUserDetailslist = new ArrayList<CompensationLeaveUserDetails>();
		try {
			compensationConsumedDAO.findAllCompensationLeave();
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}
		return CompensationLeaveUserDetailslist;
	}

	public void insertCompensationLeave(
			CompensationConsumedDTO compensationconsumedDTO)
			throws LeaveDAOException, SQLException {
		try {
			compensationConsumedDAO
					.insertCompensationLeave(compensationconsumedDTO);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void updateCompensationLeave(
			CompensationConsumedDTO compensationconsumedDTO)
			throws LeaveDAOException, SQLException, NotFoundException {
		try {
			compensationConsumedDAO
					.updateCompensationLeave(compensationconsumedDTO);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}

	public void deleteCompensationLeave(
			CompensationConsumedDTO compensationconsumedDTO)
			throws LeaveDAOException, SQLException, NotFoundException {
		try {
			compensationConsumedDAO
					.deleteCompensationLeave(compensationconsumedDTO);
		} catch (LeaveDAOException e) {
			e.printStackTrace();
		}

	}
}
